﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EnvDTE;

namespace Jwell.Template.App.Utl
{
    /// <summary>
    /// projects扩展
    /// </summary>
    public static class ProjectsExtension
    {
        /// <summary>
        /// 根据条件改变项目相关的属性
        /// </summary>
        /// <param name="project"></param>
        /// <param name="propertyName"></param>
        /// <param name="condition"></param>
        public static void ChangeProjectProperty(this Project project,string propertyName, Func<string, string> condition=null)
        {
            
            var property = project.Properties.Item(propertyName);
            if (property == null)
                return;
            string oldValue = property.Value?.ToString();
            if (condition != null)
            {
                var newVavlue = condition.Invoke(oldValue);
                property.Value = newVavlue;
            }
        }
    }
}
